/**
 * 检验数据AOP
 * @author Haijun Gao 
 * @date 2017-7-21 下午5:17:45 
 * @desp http://www.cnblogs.com/saga5998/
 * @email kfghj198858@163.com
 */
package com.smforj.ssm.frame.core.aop;

import org.aspectj.lang.JoinPoint;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.smforj.ssm.frame.core.bean.BaseBean;

/**
 * 
 * @author Haijun Gao 
 * @date 2017-7-21 下午5:17:45
 * @desp http://www.cnblogs.com/saga5998/
 * @email 573107773@qq.com
 */
public class InspectionDataAop {
	private Logger log = LoggerFactory.getLogger(this.getClass());
	 
	public void inspectionData(JoinPoint jp) { 
		log.info("inspectionData");
	      //获取目标对象对应的类名     
        String className = jp.getTarget().getClass().getName();     
        //获取目标对象上正在执行的方法名     
        String methodName = jp.getSignature().getName();  
        System.out.println("前置通知:" + className + "类的" + methodName + "方法开始了"+jp.getArgs());  
        //只会对添加进行处理
        if(jp.getArgs() != null && jp.getArgs().length > 0 && (methodName.startsWith("insert") || methodName.startsWith("add")))
        {
        	for(Object obj : jp.getArgs())
        	{
        		if(obj.getClass().getName().contains(BaseBean.class.getSimpleName()) || obj.getClass().getSuperclass().getName().contains(BaseBean.class.getSimpleName()))
        		{
        			log.info(obj.toString());
        		}
        		log.info("----"+obj.toString());
        	}
        		
        }
	}  
}
